#include <stdio.h>

int main() {
    int a[3][3] = {{1, 2, 3}, {0, 4, 5}, {0, 0, 6}};
    int sum = 0;
    int *p = &a[0][0];
    for (int i = 0; i < 3; i++) {
        for (int j = i; j < 3; j++) {
            sum += *(p + i*3 + j);
        }
    }
    printf("三角元素的和为%d\n", sum);
    return 0;
}